<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="referrer" content="never">
  <title>登录</title>
  <link rel="stylesheet" href="style.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>

  <form action="index.html" id="loginForm" name="loginForm" class="login-form">
    <h1>Login</h1>

    <div class="txtb">
      <!-- 禁用选择输入历史 为input设置 autocomplete="off" -->
      <input type="text" name="userName" autocomplete="off">
      <span data-placeholder="Username"></span>
    </div>

    <div class="txtb">
      <input type="password" name="password">
      <span data-placeholder="Password"></span>
    </div>

    <input type="submit" class="logbtn" value="Login" onclick="getValue()">

    <div class="bottom-text">
      Don't have account? <a href="#">Sign up</a>
    </div>

  </form>

  <script type="text/javascript">
    $('.txtb input').on("focus", function(){
      $(this).addClass("focus");
    });

    $('.txtb input').on("blur", function(){
      if($(this).val() == "") {
        $(this).removeClass("focus");
      }
    });

    function getValue() {
        var v1 = document.loginForm.userName.value;
        var v2 = document.loginForm.password.value;
        alert('userName = ' + v1 + '\npassword = ' + v2);
      }

  </script>

</body>

</html>